﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class BUSPhanLop
    {

        public static object DanhSachHocSinhPhanLop(DTOHocSinh hocsinh)
        {
            try
            {
                return DAOPhanLop.DanhSachHocSinhChuaCoLop(hocsinh);
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }

        public static object DanhSachLop()
        {
            try
            {
                return DAOPhanLop.DanhSachLop();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool KiemTraSiSoTrong(int SoHocSinh, string MaLop)
        {
            try
            {
                System.Data.DataTable dt = DAOPhanLop.SiSoHienTai(MaLop);
                if (SoHocSinh + (int)dt.Rows[0][0] > (int)dt.Rows[1][0])
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static int PhanLop(DTOHocSinh hocsinh)
        {
            try
            {
                int kq = DAOPhanLop.CapNhatLopHocSinh(hocsinh);
                return kq;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
